/**
 * Generate code from /{{projectName}}-core/src/main/java/{{packageName}}/core/{{modules}}/domain/{{entities@SQL}}.java.hbs
 */
package cn.ibizlab.core.ad.domain;

import java.util.*;
import cn.ibizlab.util.domain.IEntity;
import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.*;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import org.springframework.util.*;
import org.springframework.data.annotation.*;
import cn.ibizlab.util.annotation.*;
import cn.ibizlab.util.enums.*;
import cn.ibizlab.util.domain.EntityMP;
import java.io.Serializable;
import lombok.*;
import lombok.experimental.Accessors;
import io.swagger.annotations.*;
import com.baomidou.mybatisplus.annotation.*;
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import cn.ibizlab.core.ad.domain.SysDepartment;
import cn.ibizlab.core.ad.domain.SysOrganization;
import cn.ibizlab.core.open.domain.OpenAccessAuth;
import cn.ibizlab.core.ad.domain.SysMember;
import cn.ibizlab.core.ad.domain.SysCommonName;

/**
 * 人员实体类[SysPerson]
 *
 * @author generator
 */
@Audit
@Getter
@Setter
@NoArgsConstructor
@Accessors(chain = true)
@JsonIgnoreProperties(value = "handler")
@TableName(value = "SYS_PERSON", resultMap = "SysPersonResultMap")
@ApiModel(value = "SYS_PERSON", description = "人员")
public class SysPerson extends EntityMP implements Serializable
{

    /**
     * 标识
     */
    @Id
    @TableId(value = "id" , type = IdType.ASSIGN_UUID)
    @DEField(name = "id" , isKeyField = true)
    @JsonProperty("id")
    @JSONField(name = "id")
    @ApiModelProperty(value = "id", notes = "标识")
    private String id;

    /**
     * 名称
     */
    @TableField(value = "display_name")
    @DEField(name = "display_name")
    @JsonProperty("display_name")
    @JSONField(name = "display_name")
    @ApiModelProperty(value = "display_name", notes = "名称")
    private String displayName;

    /**
     * 逻辑有效标记
     */
    @TableField(value = "enabled")
    @TableLogic(value = "1" , delval = "0")
    @DEField(name = "enabled" , preType = DEPredefinedFieldType.LOGICVALID , logicval = "1" , logicdelval = "0" , dict = "YesNo")
    @JsonProperty("enabled")
    @JSONField(name = "enabled")
    @ApiModelProperty(value = "enabled", notes = "逻辑有效标记")
    private Integer enabled;

    /**
     * 创建人
     */
    @TableField(value = "creator" , fill = FieldFill.INSERT)
    @DEField(name = "creator" , preType = DEPredefinedFieldType.CREATEMAN)
    @JsonProperty("creator")
    @JSONField(name = "creator")
    @ApiModelProperty(value = "creator", notes = "创建人")
    private String creator;

    /**
     * 创建时间
     */
    @TableField(value = "create_time" , fill = FieldFill.INSERT)
    @DEField(name = "create_time" , preType = DEPredefinedFieldType.CREATEDATE)
    @JsonProperty("create_time")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", locale = "zh", timezone = "GMT+8")
    @JSONField(name = "create_time" , format = "yyyy-MM-dd HH:mm:ss")
    @ApiModelProperty(value = "create_time", notes = "创建时间")
    private Date createTime;

    /**
     * 最后更新人
     */
    @TableField(value = "updater")
    @DEField(name = "updater" , preType = DEPredefinedFieldType.UPDATEMAN)
    @JsonProperty("updater")
    @JSONField(name = "updater")
    @ApiModelProperty(value = "updater", notes = "最后更新人")
    private String updater;

    /**
     * 最后更新时间
     */
    @TableField(value = "update_time")
    @DEField(name = "update_time" , preType = DEPredefinedFieldType.UPDATEDATE)
    @JsonProperty("update_time")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", locale = "zh", timezone = "GMT+8")
    @JSONField(name = "update_time" , format = "yyyy-MM-dd HH:mm:ss")
    @ApiModelProperty(value = "update_time", notes = "最后更新时间")
    private Date updateTime;

    /**
     * DC
     */
    @TableField(value = "dc")
    @DEField(name = "dc")
    @JsonProperty("dc")
    @JSONField(name = "dc")
    @ApiModelProperty(value = "dc", notes = "DC")
    private String dc;

    /**
     * 部门辅助查询
     */
    @TableField(value = "department_id" , exist = false)
    @DEField(name = "department_id")
    @JsonProperty("department_id")
    @JSONField(name = "department_id")
    @ApiModelProperty(value = "department_id", notes = "部门辅助查询")
    private String departmentId;

    /**
     * uid/loginname
     */
    @TableField(value = "uid")
    @DEField(name = "uid" , dupCheck = DupCheck.ALL , dupCheckField = "dc")
    @JsonProperty("uid")
    @JSONField(name = "uid")
    @ApiModelProperty(value = "uid", notes = "uid/loginname")
    private String uid;

    /**
     * 密码
     */
    @TableField(value = "user_password")
    @DEField(name = "user_password")
    @JsonProperty("user_password")
    @JSONField(name = "user_password")
    @ApiModelProperty(value = "user_password", notes = "密码")
    private String userPassword;

    /**
     * 组织机构标识
     */
    @TableField(value = "organization_id")
    @DEField(name = "organization_id" , defaultValue = "000000")
    @JsonProperty("organization_id")
    @JSONField(name = "organization_id")
    @ApiModelProperty(value = "organization_id", notes = "组织机构标识")
    private String organizationId;

    /**
     * 机构编号
     */
    @TableField(value = "organization_number" , exist = false)
    @DEField(name = "organization_number")
    @JsonProperty("organization_number")
    @JSONField(name = "organization_number")
    @ApiModelProperty(value = "organization_number", notes = "机构编号")
    private String organizationNumber;

    /**
     * 组织机构名称
     */
    @TableField(value = "organization_name" , exist = false)
    @DEField(name = "organization_name")
    @JsonProperty("organization_name")
    @JSONField(name = "organization_name")
    @ApiModelProperty(value = "organization_name", notes = "组织机构名称")
    private String organizationName;

    /**
     * 人员编号
     */
    @TableField(value = "employee_number")
    @DEField(name = "employee_number" , dupCheck = DupCheck.ALL , dupCheckField = "organizationId")
    @JsonProperty("employee_number")
    @JSONField(name = "employee_number")
    @ApiModelProperty(value = "employee_number", notes = "人员编号")
    private String employeeNumber;

    /**
     * 类型
     */
    @TableField(value = "employee_type")
    @DEField(name = "employee_type")
    @JsonProperty("employee_type")
    @JSONField(name = "employee_type")
    @ApiModelProperty(value = "employee_type", notes = "类型")
    private String employeeType;

    /**
     * 职位
     */
    @TableField(value = "title")
    @DEField(name = "title")
    @JsonProperty("title")
    @JSONField(name = "title")
    @ApiModelProperty(value = "title", notes = "职位")
    private String title;

    /**
     * 电子邮箱
     */
    @TableField(value = "mail")
    @DEField(name = "mail")
    @JsonProperty("mail")
    @JSONField(name = "mail")
    @ApiModelProperty(value = "mail", notes = "电子邮箱")
    private String mail;

    /**
     * 联系电话
     */
    @TableField(value = "telephone_number")
    @DEField(name = "telephone_number")
    @JsonProperty("telephone_number")
    @JSONField(name = "telephone_number")
    @ApiModelProperty(value = "telephone_number", notes = "联系电话")
    private String telephoneNumber;

    /**
     * 移动电话
     */
    @TableField(value = "mobile")
    @DEField(name = "mobile")
    @JsonProperty("mobile")
    @JSONField(name = "mobile")
    @ApiModelProperty(value = "mobile", notes = "移动电话")
    private String mobile;

    /**
     * 证件号
     */
    @TableField(value = "identification_number")
    @DEField(name = "identification_number")
    @JsonProperty("identification_number")
    @JSONField(name = "identification_number")
    @ApiModelProperty(value = "identification_number", notes = "证件号")
    private String identificationNumber;

    /**
     * 地址
     */
    @TableField(value = "postal_address")
    @DEField(name = "postal_address")
    @JsonProperty("postal_address")
    @JSONField(name = "postal_address")
    @ApiModelProperty(value = "postal_address", notes = "地址")
    private String postalAddress;

    /**
     * 描述
     */
    @TableField(value = "description")
    @DEField(name = "description")
    @JsonProperty("description")
    @JSONField(name = "description")
    @ApiModelProperty(value = "description", notes = "描述")
    private String description;

    /**
     * DN
     */
    @TableField(value = "dn" , exist = false)
    @DEField(name = "dn")
    @JsonProperty("dn")
    @JSONField(name = "dn")
    @ApiModelProperty(value = "dn", notes = "DN")
    private String dn;

    /**
     * 主部门标识
     */
    @TableField(value = "mdepartment_id")
    @DEField(name = "mdepartment_id")
    @JsonProperty("mdepartment_id")
    @JSONField(name = "mdepartment_id")
    @ApiModelProperty(value = "mdepartment_id", notes = "主部门标识")
    private String mdepartmentId;

    /**
     * 用户组查询辅助属性
     */
    @TableField(value = "organizational_role_id" , exist = false)
    @DEField(name = "organizational_role_id")
    @JsonProperty("organizational_role_id")
    @JSONField(name = "organizational_role_id")
    @ApiModelProperty(value = "organizational_role_id", notes = "用户组查询辅助属性")
    private String organizationalRoleId;

    /**
     * 主部门
     */
    @TableField(value = "mdepartment_name" , exist = false)
    @DEField(name = "mdepartment_name")
    @JsonProperty("mdepartment_name")
    @JSONField(name = "mdepartment_name")
    @ApiModelProperty(value = "mdepartment_name", notes = "主部门")
    private String mdepartmentName;

    /**
     * 状态
     */
    @TableField(value = "status")
    @DEField(name = "status" , defaultValue = "1")
    @JsonProperty("status")
    @JSONField(name = "status")
    @ApiModelProperty(value = "status", notes = "状态")
    private String status;

    /**
     * 头像
     */
    @TableField(value = "avatar")
    @DEField(name = "avatar")
    @JsonProperty("avatar")
    @JSONField(name = "avatar")
    @ApiModelProperty(value = "avatar", notes = "头像")
    private String avatar;

    /**
     * 部门
     */
    @JsonIgnore
    @JSONField(serialize = false)
    @TableField(exist = false)
    @Transient
    @ApiModelProperty(value = "sys_department", notes = "主部门")
    private SysDepartment sysDepartment;

    /**
     * 组织机构
     */
    @JsonIgnore
    @JSONField(serialize = false)
    @TableField(exist = false)
    @Transient
    @ApiModelProperty(value = "organization", notes = "组织机构")
    private SysOrganization organization;

    /**
     * 成员
     */
    @JSONField(name = "member_ofs")
    @JsonProperty("member_ofs")
    @TableField(exist = false)
    @ApiModelProperty(value = "member_of", notes = "人员")
    private List<SysMember> memberOf;

    /**
     * 设置 [名称]
     */
    public SysPerson setDisplayName(String displayName) {
        this.displayName = displayName;
        this.modify("display_name", displayName);
        return this;
    }

    /**
     * 设置 [DC]
     */
    public SysPerson setDc(String dc) {
        this.dc = dc;
        this.modify("dc", dc);
        return this;
    }

    /**
     * 设置 [部门辅助查询]
     */
    public SysPerson setDepartmentId(String departmentId) {
        this.departmentId = departmentId;
        this.modify("department_id", departmentId);
        return this;
    }

    /**
     * 设置 [uid/loginname]
     */
    public SysPerson setUid(String uid) {
        this.uid = uid;
        this.modify("uid", uid);
        return this;
    }

    /**
     * 设置 [密码]
     */
    public SysPerson setUserPassword(String userPassword) {
        this.userPassword = userPassword;
        this.modify("user_password", userPassword);
        return this;
    }

    /**
     * 设置 [组织机构标识]
     */
    public SysPerson setOrganizationId(String organizationId) {
        this.organizationId = organizationId;
        this.modify("organization_id", organizationId);
        return this;
    }

    /**
     * 设置 [机构编号]
     */
    public SysPerson setOrganizationNumber(String organizationNumber) {
        this.organizationNumber = organizationNumber;
        this.modify("organization_number", organizationNumber);
        return this;
    }

    /**
     * 设置 [组织机构名称]
     */
    public SysPerson setOrganizationName(String organizationName) {
        this.organizationName = organizationName;
        this.modify("organization_name", organizationName);
        return this;
    }

    /**
     * 设置 [人员编号]
     */
    public SysPerson setEmployeeNumber(String employeeNumber) {
        this.employeeNumber = employeeNumber;
        this.modify("employee_number", employeeNumber);
        return this;
    }

    /**
     * 设置 [类型]
     */
    public SysPerson setEmployeeType(String employeeType) {
        this.employeeType = employeeType;
        this.modify("employee_type", employeeType);
        return this;
    }

    /**
     * 设置 [职位]
     */
    public SysPerson setTitle(String title) {
        this.title = title;
        this.modify("title", title);
        return this;
    }

    /**
     * 设置 [电子邮箱]
     */
    public SysPerson setMail(String mail) {
        this.mail = mail;
        this.modify("mail", mail);
        return this;
    }

    /**
     * 设置 [联系电话]
     */
    public SysPerson setTelephoneNumber(String telephoneNumber) {
        this.telephoneNumber = telephoneNumber;
        this.modify("telephone_number", telephoneNumber);
        return this;
    }

    /**
     * 设置 [移动电话]
     */
    public SysPerson setMobile(String mobile) {
        this.mobile = mobile;
        this.modify("mobile", mobile);
        return this;
    }

    /**
     * 设置 [证件号]
     */
    public SysPerson setIdentificationNumber(String identificationNumber) {
        this.identificationNumber = identificationNumber;
        this.modify("identification_number", identificationNumber);
        return this;
    }

    /**
     * 设置 [地址]
     */
    public SysPerson setPostalAddress(String postalAddress) {
        this.postalAddress = postalAddress;
        this.modify("postal_address", postalAddress);
        return this;
    }

    /**
     * 设置 [描述]
     */
    public SysPerson setDescription(String description) {
        this.description = description;
        this.modify("description", description);
        return this;
    }

    /**
     * 设置 [DN]
     */
    public SysPerson setDn(String dn) {
        this.dn = dn;
        this.modify("dn", dn);
        return this;
    }

    /**
     * 设置 [主部门标识]
     */
    public SysPerson setMdepartmentId(String mdepartmentId) {
        this.mdepartmentId = mdepartmentId;
        this.modify("mdepartment_id", mdepartmentId);
        return this;
    }

    /**
     * 设置 [用户组查询辅助属性]
     */
    public SysPerson setOrganizationalRoleId(String organizationalRoleId) {
        this.organizationalRoleId = organizationalRoleId;
        this.modify("organizational_role_id", organizationalRoleId);
        return this;
    }

    /**
     * 设置 [主部门]
     */
    public SysPerson setMdepartmentName(String mdepartmentName) {
        this.mdepartmentName = mdepartmentName;
        this.modify("mdepartment_name", mdepartmentName);
        return this;
    }

    /**
     * 设置 [状态]
     */
    public SysPerson setStatus(String status) {
        this.status = status;
        this.modify("status", status);
        return this;
    }

    /**
     * 设置 [头像]
     */
    public SysPerson setAvatar(String avatar) {
        this.avatar = avatar;
        this.modify("avatar", avatar);
        return this;
    }


    @Override
    public Serializable getDefaultKey(boolean gen) {
        //Assert.notNull(getUid(),"未设置uid/loginname");
        //Assert.notNull(getDc(),"未设置DC");
        String key = String.format("%s||%s"
            ,getUid(),getDc());
        key = DigestUtils.md5DigestAsHex(key.getBytes());    
        return key;
    }

    /**
     * 复制当前对象数据到目标对象(粘贴重置)
     * @param targetEntity 目标数据对象
     * @param includeEmpty  是否包括空值
     * @param <T>
     * @return
     */
    @Override
    public <T> T pasteTo(T targetEntity, boolean includeEmpty) {
        super.pasteTo(targetEntity, includeEmpty);
        if(targetEntity instanceof IEntity) {
            IEntity entity = ((IEntity) targetEntity);
            entity.reset("id");
        }
        return targetEntity;
    }

}